package com.rrd.itext.xmlBean.wrapper;

import com.rrd.itext.xmlBean.converter.DataZoneConverter;
import com.rrd.itext.xmlBean.converter.HtmlBlockConverter;
import com.rrd.itext.xmlBean.converter.XmlTextConverter;
import com.rrd.itext.xmlBean.layoutBean.XmlBaseBean;
import com.rrd.itext.xmlBean.layoutBean.XmlColumns;
import com.rrd.itext.xmlBean.layoutBean.XmlList;
import com.rrd.itext.xmlBean.layoutBean.XmlListItem;
import com.rrd.itext.xmlBean.layoutBean.XmlPage;
import com.rrd.itext.xmlBean.layoutBean.XmlParagraph;
import com.rrd.itext.xmlBean.layoutBean.XmlSection;
import com.rrd.itext.xmlBean.layoutBean.XmlTable;
import com.rrd.itext.xmlBean.layoutBean.XmlTd;
import com.rrd.itext.xmlBean.layoutBean.XmlTr;
import com.rrd.itext.xmlBean.layoutBean.XmlZone;
import com.thoughtworks.xstream.XStream;

public class LayoutXStreamWrapper {
	private static final String SECTIONS = "sections";
	private static final String PAGES = "pages";
	private static final String ZONES = "zones";
	private static final String PHRASES = "phrases";
    private static final String CHUNKS = "chunks";
    private static final String HTMLBLOCKS = "htmlBlocks";
	private static final String LISTITEMS = "listItems";
	private static final String LISTS = "lists";
	private static final String TRS = "trs";
	private static final String TDS = "tds";

	private XStream xstream;

	public XStream initXStream() {
		xstream = new XStream();
		xstream.processAnnotations(XmlBaseBean.class);
		xstream.addImplicitCollection(XmlBaseBean.class, SECTIONS);
		xstream.addImplicitCollection(XmlSection.class, PAGES);
		xstream.addImplicitCollection(XmlPage.class, ZONES);
		xstream.addImplicitCollection(XmlZone.class, PHRASES);
        xstream.addImplicitCollection(XmlParagraph.class, CHUNKS);
        xstream.addImplicitCollection(XmlParagraph.class, HTMLBLOCKS);
        xstream.addImplicitCollection(XmlColumns.class, HTMLBLOCKS);
		xstream.addImplicitCollection(XmlList.class, LISTITEMS);
		xstream.addImplicitCollection(XmlListItem.class, CHUNKS);
		xstream.addImplicitCollection(XmlTable.class, TRS);
		xstream.addImplicitCollection(XmlTr.class, TDS);
		xstream.addImplicitCollection(XmlTd.class, PHRASES);
		
		
		HtmlBlockConverter htmlBlockConverter = new HtmlBlockConverter();
		xstream.registerConverter(htmlBlockConverter);
		
		DataZoneConverter dataZoneConverter = new DataZoneConverter();
        xstream.registerConverter(dataZoneConverter);
        
        XmlTextConverter xmlTextConverter = new XmlTextConverter();
        xstream.registerConverter(xmlTextConverter);
        
		return xstream;
	}

	public XStream getXstream() {
		return xstream;
	}

	public void setXstream(XStream xstream) {
		this.xstream = xstream;
	}

}
